const emptyDefaultImg = '/images/error/empty-default.png'
const emptyErrorImg = '/images/error/empty-error.png'
const emptyNetworkImg = '/images/error/empty-network.svg'
const emptySearchImg = '/images/error/empty-search.png'

const host = 'https://123.57.179.178'

const colorDefault = '#0052d9'

const colorGrayDefault = '#999999'

function apiErrorStatus (error) {
  let endStatus = {
    type: 'ERR',
    desc: typeof (error.data.data.msg) === 'string' ? error.data.data.msg : '未知错误'
  }

  switch (error.data.data.state) {
    // case -201:
    //   endStatus.code = -201
    //   endStatus.image = emptyDefaultImg
    //   endStatus.hideBtn = true
    //   break
    
    default:
      endStatus.image = emptyErrorImg
  }

  return endStatus
}

function apiEndStatus (error) {
  let endStatus = {
    type: 'ERR'
  }

  switch (error.type) {
    case 'FAIL':
      endStatus = { image: emptyErrorImg, desc: '未知请求错误' }
      break
    case 'HTTP':
      endStatus = { image: emptyNetworkImg, desc: `请求失败${error.data.statusCode}` }
      break
    case 'API':
      endStatus = apiErrorStatus(error)
      break
    case 'LOGIN':
      endStatus = { image: emptyDefaultImg, desc: '您还没有登录哦~', hideBtn: true }
      break
    default:
      endStatus = { image: emptyErrorImg, desc: '未知代码错误' }
  }

  return endStatus
}

export {
  host,
  colorDefault,
  colorGrayDefault,
  emptyDefaultImg,
  emptyErrorImg,
  emptyNetworkImg,
  emptySearchImg,
  apiErrorStatus,
  apiEndStatus
}